#include<stdio.h>
int main()
{
	int m = 1, n = 1,N=1;
	printf("请输入行数：");
	scanf("%d", &n);
    N=(n+1)/2;
	for (m = 1; m <= N; m++) {
		int a = 1, b = 1;
		while (a <= N - m) {
			printf(" ");
			a++;
		}
		while (b <= 2 * m - 1) {
			printf("*");
			b++;
		}
		printf("\n");
	}
	for (m = 1; m < N; m++)//因为正倒三角形共用底边，故可以使倒三角形少打印底边，m<N即可
	{
		int a = 1, b = 1;
		while (a <= m)//空格数与不算底边的倒三角形相同
		{
			printf(" ");
			a++;
		}
		while (b <= 2 * (N - m) - 1) //N-m为剩余的行数
		{
			printf("*");
			b++;
		}
		printf("\n");
	}
	return 0;
}